package com.example.sell.config;

//import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import com.lly835.bestpay.config.WxPayConfig;
import com.lly835.bestpay.service.impl.BestPayServiceImpl;
import me.chanjar.weixin.mp.bean.WxMpHostConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author: vince_zww
 * @date: 2020/8/24 15:15
 * @desceription: 支付配置
 */
@Component
public class WechatPayConfig {

    @Autowired
    private WechatAccountConfig accountConfig;

//    @Bean
//    public WxPayServiceImpl wxPayService() {
//        WxPayServiceImpl wxPayService = new WxPayServiceImpl();
//        wxPayService.setConfig(wxPayConfig());
//
//        return wxPayService;
//    }
//
//    @Bean
//    public WxPayConfig wxPayConfig() {
//        WxPayConfig wxPayConfig = new WxPayConfig();
//        wxPayConfig.setAppId(accountConfig.getMpAppId());
////        wxPayConfig.setAppSecret(accountConfig.getMpAppSecret());
//        wxPayConfig.setMchId(accountConfig.getMchId());
//        wxPayConfig.setMchKey(accountConfig.getMchKey());
//        wxPayConfig.setKeyPath(accountConfig.getKeyPath());
//        return wxPayConfig;
//    }

    @Bean
    public BestPayServiceImpl bestPayService(){
        BestPayServiceImpl bestPayService = new BestPayServiceImpl();
        bestPayService.setWxPayConfig(wxPayConfig());
        return bestPayService;
    }

    @Bean
    public WxPayConfig wxPayConfig(){
        WxPayConfig wxPayConfig = new WxPayConfig();
        wxPayConfig.setAppId(accountConfig.getMpAppId());
        wxPayConfig.setAppSecret(accountConfig.getMpAppSecret());
        wxPayConfig.setMchId(accountConfig.getMchId());
        wxPayConfig.setMchKey(accountConfig.getMchKey());
        wxPayConfig.setKeyPath(accountConfig.getKeyPath());
        wxPayConfig.setNotifyUrl(accountConfig.getNotifyUrl());
        return wxPayConfig;
    }



}
